<?php
include_once 'controller/default.php';
include_once 'connection/connection_database.php';

class contact {

    function Insert($contact) {
        $sql = "INSERT INTO contact(contact_address, contact_city, contact_phone, contact_telephone, contact_fax, contact_email)"; 
        $sql .= "VALUES('{$contact["contact_address"]}', '{$contact["contact_city"]}', '{$contact["contact_phone"]}', '{$contact["contact_telephone"]}', '{$contact["contact_fax"]}', '{$contact["contact_email"]}')";
        $result = mysql_query($sql) or die(mysql_error());
        return $result;
    }

    function Delete($contact) {
        $sql = "DELETE FROM contact WHERE contact_id='{$contact["id"]}'";
        $result = mysql_query($sql) or die(mysql_error());
        return $result;
    }

    function Update($contact) {
        $sql = "UPDATE contact SET contact_address='{$contact["contact_address"]}', contact_city='{$contact["contact_city"]}', contact_phone='{$contact["contact_phone"]}', contact_telephone='{$contact["contact_telephone"]}', contact_fax='{$contact["contact_fax"]}', contact_email='{$contact["contact_email"]}' WHERE contact_id='{$contact["id"]}'";
        $result = mysql_query($sql) or die(mysql_error());
        return $result;
    }

    function FillAll() {
        $sql = "SELECT * FROM contact WHERE contact_status = 1";
        $result = mysql_query($sql) or die(mysql_error());
        return $result;
    }

    function FillOne($contact) {
        $sql = "SELECT * FROM contact WHERE contact_id='{$contact["id"]}'";
        $result = mysql_query($sql) or die(mysql_error());
        return mysql_fetch_array($result);
    }

}

?>
